package com.zhidian.edm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhidian.edm.entity.SysTokenPO;
import com.zhidian.edm.mapper.SysTokenMapper;
import com.zhidian.edm.service.ISysTokenService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sl
 * @since 2025-09-18
 */
@Service
public class SysTokenServiceImpl extends ServiceImpl<SysTokenMapper, SysTokenPO> implements ISysTokenService {

    @Resource
    private SysTokenMapper sysTokenMapper;

    @Override
    public Optional<SysTokenPO> findByToken(String token) {
        LambdaQueryWrapper<SysTokenPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysTokenPO::getToken, token);
        SysTokenPO dbToken = sysTokenMapper.selectOne(wrapper);
        return Optional.ofNullable(dbToken);
    }
}
